const http = require("http")
const serve = http.createServer()
serve.on('request', (req, res) => {
  let content = '404 not found!'
  if (req.url === '/' || req.url === '/index.html') {
    content = '现在打开的是首页'
  }
  if (req.url === '/about.html') {
    content = '现在打开的是关于页面'
  }
  res.setHeader('Content-Type', 'text/html;charset=utf-8')
  res.end('<h1>' + content + '</h1>')
})
serve.listen(8080, () => {
  console.log('server runing at http://127.0.0.1')
})